﻿@using Masuit.MyBlogs.Domain.Entity
@using Masuit.MyBlogs.Domain.Enum
@using Masuit.MyBlogs.Services.DTO
@using Masuit.Tools.Helper
@using Masuit.Tools
@using Masuit.Tools.Html
@using Masuit.Tools.Systems
@{
    string[] colors = { "success", "info", "primary", "warning", "danger", "default", "primary" };
}
@model  PostDto
<div class="ibox wow fadeIn">
    <div class="ibox-content">
        <a asp-controller="Post" asp-action="Details" asp-route-id="@Model.Id" target="_blank">
            <h4>
                @if (Model.IsFixedTop)
                {
                    <i class="icon-thumbsup fixtop">[顶]</i>
                }
                @if (DateTime.Now - Model.ModifyDate < TimeSpan.FromDays(1))
                {
                    <i class="new">[新]</i>
                }
                @Model.Title
            </h4>
        </a>
        <div class="row padding-bot10">
            @{
                //随机取合适大小的图片
                string imgSrc = Model.Content.MatchRandomImgSrc();
                if (!string.IsNullOrEmpty(imgSrc))
                {
                    <div class="col-sm-3">
                        <img class="img-thumbnail img-responsive thumb" data-original="@imgSrc" alt="@Model.Title">
                    </div>
                }
            }
            <div class="col-sm-@(string.IsNullOrEmpty(imgSrc) ? 12 : 9)">
                <div class="small padding-bot10">
                    作者：<i class="icon-user-check"></i><strong class="label label-primary">
                        <a asp-controller="Home" asp-action="Author" asp-route-author="@Model.Author">@Model.Author</a>
                    </strong> <span class="text-muted">
                        | 发表时间：<i class="fa fa-clock-o"></i> @Model.ModifyDate.ToString("yyyy-MM-dd HH:mm") |
                        分类：<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.CategoryId">@Model.CategoryName</a>
                    </span>
                </div>
                <p>
                    @Html.Raw(Model.Content.GetSummary(150, 50))
                </p>
            </div>
        </div>
        <div class="row">
            @if (!string.IsNullOrEmpty(Model.Label))
            {
                <div class="col-md-5">
                    @foreach (string s in Model.Label.Split(',', '，'))
                    {
                        <a asp-controller="Home" asp-action="Tag" asp-route-id="@s" target="_blank">
                            <span class="label label-@colors[new Random().Next() % colors.Length]">@s</span>
                        </a>
                    }
                </div>
            }
            <div class="col-md-7 pull-right">
                <div class="small text-right">
                    <i class="fa fa-comments-o"></i>@Model.CommentCount 评论 |
                    <i class="fa fa-eye"></i>@Model.TotalViewCount 浏览 |
                    <i class="icon-thumbsup"></i>@Model.VoteUpCount 支持 |
                    <span class="text-danger"><i class="icon-recycle"></i>状态：@Model.Status.GetDisplay()</span>
                </div>
            </div>
        </div>
    </div>
</div>
